﻿package Classes.Layers{
	import flash.display.*;
	import flash.events.*;
	import flash.filters.DropShadowFilter;
	
	import Classes.Maps.*;
	import Classes.Utils.*;
	
	public class Layer extends Sprite{
		static public const GROUND:uint = 1;
		static public const BULLET:uint = 3;
		static public const SKY:uint = 4;
		static public const PLAYER:uint = 4;		
		static public const BONUS:uint = 5;		
		static public const EXPLODE:uint = 6;		
		//shadow filter
		private var _useShadow:Boolean;
		private var dropshadow:DropShadowFilter;
		private var shadowdistance:Number;
		private var shadowangle:Number;
		private var shadowalpha:Number;
		private var blurX:Number = 2;
		private var blurY:Number = 2;	
		
		private var i:int;
		public var layerType:uint;
		
		public function Layer(ltype:uint){
			layerType = ltype;
			setShadowParm();
		
		}
		
		public function clearLayer():void{
			for(i = 0;i<this.numChildren;i++){
				this.removeChildAt(i);
			}
		}
		
		public function set useShadow(value:Boolean):void{
			if(layerType == Layer.BULLET)
				return;
			_useShadow = value;			
			if(_useShadow){
				dropshadow = new DropShadowFilter(shadowdistance,shadowangle,0x000000,shadowalpha,blurX,blurY);
				this.filters = [dropshadow];
			}else{
				dropshadow = null;
				this.filters = [];
			}
		}
		public function get useShadow():Boolean{			
			return _useShadow;
		}
		
		private function setShadowParm():void{
			if(layerType == Layer.BULLET)
				return;
			switch(layerType){
				case Layer.GROUND:
					shadowdistance = 5;
					shadowangle = -30;
					shadowalpha = .3;
					break;
				case Layer.SKY:
					shadowdistance = 35;
					shadowangle = -30;
					shadowalpha = .3;
					break;
				case Layer.PLAYER:
					shadowdistance = 45;
					shadowangle = -30;
					shadowalpha = .3;
					break;
				default:
					shadowdistance = 35;
					shadowangle = -30;
					shadowalpha = .3;					
					break;
			}
		}
		
	}
}